<?php

namespace App\Admin\Controllers;

use App\operationlog;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class OperationlogController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = 'App\operationlog';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new operationlog());
        $grid->disableExport();
        $grid->disableCreation();


//        $grid->disableCreateButton();
        $grid->disableActions();
        $grid->column('id', __('Id'));
        $grid->column('uid', __('操作人id'));
        $grid->column('username', __('操作人'));
        $grid->column('path', __('Path'));
        $grid->column('method', __('Method'));
        $grid->column('ip', __('ip'));
        $grid->column('input', __('修改内容'));
        $grid->column('created_at', __('操作时间'));
//        $grid->column('updated_at', __('Updated at'));

        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(operationlog::findOrFail($id));

        $show->field('id', __('Id'));
        $show->field('uid', __('Uid'));
        $show->field('username', __('Username'));
        $show->field('path', __('Path'));
        $show->field('method', __('Method'));
        $show->field('ip', __('Ip'));
        $show->field('input', __('Input'));
        $show->field('created_at', __('Created at'));
        $show->field('updated_at', __('Updated at'));

        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new operationlog());

        $form->number('uid', __('Uid'));
        $form->text('username', __('Username'));
        $form->text('path', __('Path'));
        $form->text('method', __('Method'));
        $form->ip('ip', __('Ip'));
        $form->textarea('input', __('Input'));

        return $form;
    }
}
